package com.loongtech.bi.manager.pay;

import com.loongtech.bi.entity.pay.EntityFirstPayUser;
import com.loongtech.bi.manager.player.TypeNewManager;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class FirstPayUserManager extends TypeNewManager<EntityFirstPayUser> {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 根据开始结束时间，求DAU
	 * @param dateStart
	 * @param dateEnd
	 * @return
	 */
	public List<EntityFirstPayUser> getFirstPayUserByDate(Date dateStart, Date dateEnd) {
		return findByQuery("from EntityFirstPayUser where 1=1 and day>=:dayStart and day<=:dayEnd order by day", "dayStart", dateStart, "dayEnd", dateEnd);
	}

    public List<Object[]> getNewUserByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
        return getFirstPayUserByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
    }

	/**
	 * 根据开始结束时间，求DAU
	 * @param dateStart
	 * @param dateEnd
	 * @return
	 */
	public List<Object[]> getFirstPayUserByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer) {
		return findByQuery("select date_format(day,'%Y-%m-%d'),firstpayuser from EntityFirstPayUser  where 1=1 and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+" ' and firstpayuser is not null", "dayStart", dateStart, "dayEnd", dateEnd);
	}
}
